home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / bpl70n12.zip / ARISOURC.ZIP / LMUL.ASM < prev    next >
Assembly Source File  |  1993-02-10  |  2KB  |  58 lines

  1.  
  2. ; *******************************************************
  3. ; *                                                     *
  4. ; *     Turbo Pascal Runtime Library Version 7.0        *
  5. ; *     Longint Multiplication                          *
  6. ; *                                                     *
  7. ; *     Copyright (C) 1991-1993 Norbert Juffa           *
  8. ; *                                                     *
  9. ; *******************************************************
  10.  
  11.              TITLE   LMUL
  12.  
  13.  
  14. CODE         SEGMENT BYTE PUBLIC
  15.  
  16.              ASSUME  CS:CODE
  17.  
  18. ; Publics
  19.  
  20.              PUBLIC  LongMul
  21.  
  22.  
  23. ;-------------------------------------------------------------------------------
  24. ; LongMul computes the product of its arguments, two LONGINT values. No check
  25. ; is made if the result overflows the LONGINT format.
  26. ;
  27. ; INPUT:     DX:AX      multiplicand
  28. ;            BX:CX      multiplicator
  29. ;
  30. ; OUTPUT:    DX:AX      product of multiplicand & multiplicator, if no overflow
  31. ;
  32. ; DESTROYS:  AX,DX,SI,DI,Flags
  33. ;-------------------------------------------------------------------------------
  34.  
  35. LongMul      PROC    FAR
  36.              MOV     DI, DX            ; save hi-word of multiplicand
  37.              OR      DI, BX            ; both numbers positive and < 65536?
  38.              JZ      $short            ; single multiplication sufficient
  39.              MOV     DI, DX            ; save hi-word of multiplicand
  40.              MOV     SI, AX            ; save lo-word of multiplicand
  41.              MUL     BX                ; multiplicator hi * multiplicand lo
  42.              XCHG    AX, DI            ; save product1 lo, get m'plicand hi
  43.              MUL     CX                ; multiplicator lo * multiplicand hi
  44.              XCHG    AX, SI            ; save procduct2 lo, get m'plicand lo
  45.              ADD     SI, DI            ; add product1 and product2 (result hi)
  46.              MUL     CX                ; multiplicator lo * multiplicand lo
  47.              ADD     DX, SI            ; add product3 hi to result hi
  48.              RET                       ; done
  49. $short:      MUL     CX                ; lo-word m'plicand * lo-word m'plicator
  50.              RET                       ; done
  51. LongMul      ENDP
  52.  
  53.              ALIGN   4
  54.  
  55. CODE         ENDS
  56.  
  57.              END
  58.